﻿@{
    string id = MxTol.UI.Helpers.WebQueryHelper.QueryString("id");
 }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
       <script src="/Contents/scripts/jquery-1.8.0.min.js" type="text/javascript"></script>
        <script src="/Contents/scripts/functions.js" type="text/javascript"></script>
        <link href="/Contents/css/glassbtn.css" rel="stylesheet" type="text/css" />
        <script src="/Contents/scripts/md5.js" type="text/javascript"></script>
        <script src="/Contents/scripts/manager-js/admin-manager.js" type="text/javascript"></script>
        <style type="text/css">
            .left{float:left; width:100px; text-align:right;font-family:微软雅黑;color:#444444;line-height:26px;margin-bottom:8px;}
            .right{float:left;}
            
            .shuru{border:1px solid #ccc; height:23px; width:170px;line-height:23px; text-indent:5px;margin-bottom:8px;}
            .shuru:hover{border:1px solid #88C5EE; height:23px; line-height:23px; text-indent:5px;}
        </style>
    </head>
    <body style="padding-left:5px;padding-top:5px;">
        <div style="float:left;" >
            <span class="left">原密码：</span>
            <span class="right">
                <input  type="password" class="shuru" id="old" />
            </span>
            <span class="left">新密码：</span>
            <span class="right">
                <input type="password" class="shuru" id="new" />
            </span>
            <span class="left">确认新密码：</span>
            <span class="right">
                <input type="password" class="shuru" id="new_repeat" />
            </span>
        </div> 
        <div style="float:left;">
            <input type="button" class="greenbtn" style="width:70px;margin-left:100px;margin-top:15px;" value="修改" name="update_btn" onclick="updatePswrod()"/>
        </div>
        <div style="float:left;">
            <input type="button" class="greenbtn" style="width:70px;margin-top:15px;margin-left:25px;" value="取消" name="cancel_btn" onclick="admin_info_closeForm()" />
         </div>
        <script type="text/javascript">
            $(document).ready(function () {
                var text = document.getElementById("old");
                text.focus();
            })
            function admin_info_closeForm() {
                parent.closeShade();
            }
            function updatePswrod() {
                var oldps = trim($("#old").val());
                var newps = trim($("#new").val());
                var newps_repeat = trim($("#new_repeat").val());

                if (oldps.length == 0) {
                    alert("请输入旧密码!");
                    return;
                }
                if (newps.length == 0) {
                    alert("请输入新密码!");
                    return;
                }
                if (newps.length < 6 || newps.length > 20) {
                    alert("请输入长度为 6 - 20 位的新密码!");
                    return;
                }
                if (newps_repeat.length == 0) {
                    alert("请再次输入新密码!");
                    return;
                }
                if (newps_repeat != newps) {
                    alert("二次输入的新密码不一致!");
                    return;
                }
                else {
                    ajaxUpdatePsword("@id", oldps, newps);
                }
            }
            function ajaxUpdatePsword(id, oldps, newps) {
                $.ajax({
                    type: 'GET',
                    url: '/AdminsManagement/UpdatePsword?t=' + Math.random(),
                    data: { id: id, oldps: md5(oldps), newps: md5(newps)},
                    success: function (data) {
                        if (data == "0") {
                            alert("出现未知异常导致需该密码失败,请重试!");
                        } else if (data == "1") {
                            alert("请输入长度为 6 - 20 位的新密码!");
                        }
                        else if (data == "2") {
                            alert("原密码错误!");
                        }
                        else if (data == "3") {
                            alert("密码修改成功!");
                        }
                    }
                });
            }
        </script>
    </body>
</html>
